//
//  DetaiGoodShopTableViewCellOfLabel.m
//  BTRIP
//
//  Created by johnbk on 15/11/13.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "DetaiGoodShopTableViewCellOfLabel.h"
#import "SuitableHeight.h"
@implementation DetaiGoodShopTableViewCellOfLabel

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)dealloc{
	[_label release];
	[_contentOnLabel release];
	[super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
	self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
	if (self) {
		[self createView];
	}
	return  self;
}
- (void)createView{
	self.label = [[UILabel alloc]init];
	[self.contentView addSubview:self.label];
	self.label.numberOfLines = 0;
	self.label.lineBreakMode =  NSLineBreakByWordWrapping;
	[self.label release];
}
- (void)layoutSubviews{
	[super layoutSubviews];
	self.label.font = [UIFont systemFontOfSize:12];
	
	self.label.frame = CGRectMake(20, 10, self.frame.size.width - 40, self.height);
	
	
	
}
- (void)setContentOnLabel:(NSString *)contentOnLabel{
	[self layoutSubviews];
	//NSLog(@"label = %f", self.label.frame.size.width);
	self.height = [SuitableHeight suitableHeight:contentOnLabel andWidth:self.label.frame.size.width andFont:12];
	//NSLog(@"self.height = %f", self.height);
	self.label.text = contentOnLabel;
	[self layoutSubviews];
}
+ (DetaiGoodShopTableViewCellOfLabel *)tableView:(UITableView *)tableView{
	static NSString *cellIdentifier = @"DetaiGoodShopTableViewCellOfLabelIdentifier";
	DetaiGoodShopTableViewCellOfLabel *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
	if (!cell) {
		cell = [[DetaiGoodShopTableViewCellOfLabel alloc]init];
		
	}
	return cell;
}

@end
